package com.action;

import com.dto.User;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.service.UserService;

import javax.annotation.Resource;
import javax.servlet.http.Cookie;

/**
 * Created by hxw on 2017-6-14.
 */
public class UserAction extends ActionSupport implements ModelDriven<User>{
    private User user=new User();
    @Resource(name = "userServiceImpl")
    UserService us;
    public String register(){

        return us.register(user);
    }

    public String login(){
        String s=us.login(user);
        if(s==SUCCESS){
            Cookie cookie=new Cookie("user",s);
        }
        return s;
    }


    @Override
    public User getModel() {
        return user;
    }
}
